#include <stdio.h>

int main()
{
	int arr1[100000] = {0};
	int arr2[100000] = {0};
	int i = 0;
	int h = 0;
	int point = 0;
	int l = 0;
	int m = 0;
	int rest = 0;
	
	scanf("%d %d",&l,&m);
    while(i<=l)
    {
    	arr1[i] = 1;
    	i++;
	}
	i = 0;
    while(i<2*m)
    {
    	scanf("%d",&point);
    	arr2[i] = point;
    	i++;
	}
	i = 0;
    while(i<2*m)
    {
    	h = arr2[i];
		while(h<=arr2[i+1])
		{
			arr1[h] = 0;
			h++;
		}
		i+=2;
	}
	i = 0;
	while(i<=l)
	{
		if(arr1[i] ==1)
		{
			rest++;
			i++;
		}
		else
		{
			i++;
			continue;
		}
	}
	
	printf("%d",rest);
	
	return 0;
}
